<?php
/**
 * Arrow schema descriptor 
 * 
 * @version 1.0
 * @license  GNU GPL
 * @author Artur Kmera <artur.kmera@arrowplatform.org> 
 */
class ArrowSchemaDesctiptor{
	
	/**
	 * Schema list reference
	 *
	 * @var ArrowSchemasList
	 */
	private $schemaListReference;
	
	
	/**
	 * Id of schema
	 *
	 * @var String
	 */
	private $id;
	
	/**
	 * Name of schema
	 *
	 * @var String
	 */
	private $name;

	/**
	 * File of schema (with path)
	 *
	 * @var String
	 */
	private $dir;

	/**
	 * Description
	 *
	 * @var String
	 */
	private $description;
	
	/**
	 * Constructor
	 *
	 * @param String $id
	 * @param String $name
	 * @param String $file
	 */
	public function __construct( $schemaListReference, $id, $name, $dir, $description ){
		$this->schemaListReference = $schemaListReference;
		$this->id = $id;
		$this->name = $name;
		$this->dir = $dir;
		$this->description = $description;
	}
	
	/**
	 * Returns schema list reference
	 *
	 * @return ArrowSchemasList
	 */
	public function getSchemaListReference(){
		return $this->schemaListReference;
	}

	/**
	 * Returns schema id
	 *
	 * @return String
	 */
	public function getId(){
		return $this->id;
	}	
	
	/**
	 * Returns schema Name
	 *
	 * @return String
	 */
	public function getName(){
		return $this->name;
	}
	
	/**
	 * Return schemas directory
	 *
	 * @return String
	 */
	public function getDir(){
		return $this->dir;
	}
	
	/**
	 * Returns schema file
	 *
	 * @return String
	 */
	public function getFile(){
		return $this->dir."/schema.tpl";
	}
	
	/**
	 * Returns schema class file
	 *
	 * @return String
	 */
	public function getClassFile(){
		return $this->dir."/SchemaClass.php";
	}

	/**
	 * Returns schema description
	 *
	 * @return String
	 */
	public function getDescription(){
		return $this->description;
	}
	
	/**
	 * Return names of blocks in array
	 *
	 * @return unknown
	 */
	public function getBlocksNames( ){
		$blocks = array();
		$source = file_get_contents($this->getFile());
		preg_match_all( "/<block:bound +?name=\"(.*?)\" *?>/", $source, $regs );
		foreach ( $regs[1] as $blockName ){
			$blocks[] = $blockName;
		}

		return $blocks;
	}
}
?>
